package com.ch3cooh.registry.util;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @功能:
 * @作者:chanson
 * @时间:2018/4/27 22:56
 */
public class NetworkUtils {

    public static String  getHost() {
        InetAddress addr = null;
        try {
            addr = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        String host=addr.getHostAddress(); //获取本机ip
        return host;
    }

    public static String getComputerName(){
        InetAddress addr = null;
        try {
            addr = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        String hostName=addr.getHostName(); //获取本机计算机名称
        return hostName;
    }



}
